//
//  TimerTableCell.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/25.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit
protocol TimerDelegate: class {
    func startTimer(tag:Int,btn:TimerBtn)
}
class TimerTableCell: CommonTableViewCell {
    weak var delegate:TimerDelegate?
    lazy var timerBtn:TimerBtn = {
        let btn = TimerBtn()
        btn .addTarget(self, action: #selector(getSMSCode(button:)), for: UIControlEvents.touchUpInside)
        return btn
    }()
    
    override func setUpUI() -> Void {
        super.setUpUI()
        
        self.contentView.addSubview(self.timerBtn)
        self.timerBtn.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.height.equalTo(42)
            make.right.equalToSuperview().offset(-5)
            make.width.lessThanOrEqualTo(145)
        }
        
        self.contentView.addSubview(self.numTextField)
        self.numTextField.snp.makeConstraints({ (make) in
            make.left.equalToSuperview().offset(16)
            make.right.equalTo(self.timerBtn.snp.left).offset(-5)
             make.top.bottom.equalToSuperview()
        })
        
        
    }
    
    override func setIteam(_ item: CYTableviewItem) {
        super.setIteam(item)
        self.numTextField.placeholder = item.placeHolder
        self.numTextField.setPlaceholderColor()
    }
    
    @objc func getSMSCode(button:TimerBtn) {
        if self.delegate != nil && self.delegate?.startTimer != nil {
            self.delegate?.startTimer(tag: self.tag,btn: button)
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
